package com.example.helloandroid;

import android.app.Activity;
//import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioGroup;
import android.widget.RadioButton;
import android.widget.Toast;
import android.widget.CheckBox;




public class HelloAndroid extends Activity {

	//View objects
    RadioGroup rgOptions;
    CheckBox cbWtfFaktor;
    CheckBox cbOmgFaktor;
 
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
	    rgOptions 	= (RadioGroup)findViewById(R.id.radioGroup1);
	    cbWtfFaktor = (CheckBox)findViewById(R.id.checkBox1);
	    cbOmgFaktor = (CheckBox)findViewById(R.id.checkBox2);

    
    }
    
    //Global methods
    private String getRadioGroupValue (RadioGroup rgRGroup) {
    	RadioButton rbSelected=(RadioButton)findViewById(rgRGroup.getCheckedRadioButtonId());
    	return (String)rbSelected.getTag();
    }
    
    public void Quit(View v){
    	finish();
    
    }
    
    private void showToast(CharSequence sToastText){
        Toast toast = Toast.makeText(getApplicationContext(), sToastText, Toast.LENGTH_SHORT);
        toast.show();
    }

    
    public void cmdWorkOnClick(View v){
    	String selectedText = getRadioGroupValue(rgOptions);
		StartChildActivity(selectedText);
    }
    
    private void StartChildActivity(String nadavka){
    	if (cbWtfFaktor.isChecked()){
    		WtfFactor();
    	}
    	
    	Intent i = new Intent(this, ChildActivity.class);
    	i.putExtra("NADAVKA", nadavka);
    	i.putExtra("OMG", Boolean.toString(cbOmgFaktor.isChecked()));
    	startActivity(i);

    }
    
    private void WtfFactor() {
       showToast(getString(R.string.tWtfString));
    }
}